class Admin::PagesController < ApplicationController
	before_filter :login_required
	before_filter :find_category
	
	def edit
		@page = @category.page
	end
	
	def update
		@category.page ||= Page.new(:title=>@category.title)
		@category.page.update_attributes!(params[:page])
		#@category.save! && @category.page.save!
		redirect_to admin_categories_path
		rescue ActiveRecord::RecordInvalid
    	render :action => 'edit'
	end
	
	private
	
	def find_category
		@category = Category.find_by_slug(params[:category_id])
	end
end
